package com.dream.utils.io;

import org.apache.commons.lang.StringUtils;

/***
 * 
 * @copyright evan
 * @author evan
 * @Revision
 * @date 2013-9-16
 */
public class MyFileNameUtils {
	
	public static class FileInfo{
		
		private final String name;
		
		private final String ext;
		
		public FileInfo(String name,String ext){
			this.name = name;
			this.ext = ext;
		}
		public String getName() {
			return name;
		}

		public String getExt() {
			return ext;
		}

		
	}
	public static FileInfo getFileInfo(String fullName){
		
		if(StringUtils.isBlank(fullName) || !fullName.contains(".")){
			throw new RuntimeException("Fill name is illegal");
		}
		
		int last = fullName.lastIndexOf(".");
		if(last < 0){
			throw new RuntimeException("Fill name is illegal");
		}
		String name = fullName.substring(0, last);
		String ext = fullName.substring(last+1);
		return new FileInfo(name,ext);
		
		
	}
}
